package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextPaint;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.LayoutParams;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnLastItemVisibleListener;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshBase.State;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.handmark.pulltorefresh.library.extras.SoundPullEventListener;
import com.hsc.yalebao.adapter.ReturnwaterListAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.HuiShuiListBean;
import com.hsc.yalebao.model.HuiShuiStatusBean;
import com.hsc.yalebao.model.ReturnwaterResultBaseBean;
import com.hsc.yalebao.model.ReturnwaterResultModel;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tabIndex.CustomServiceActivity;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import okhttp3.Call;

public class HuiShuiActivity extends BaseActivity
{
  private String TAG = "HuiShuiActivity";
  private ReturnwaterListAdapter adapter;
  private Context context;
  private String ctype = "1";
  private View emptyView;
  private GridView gv_home;
  private HuiShuiListBean huiShuiListBean;
  private boolean isClear;
  private boolean isEnd = false;
  private boolean isRefesh = true;
  private ImageView iv_title_right;
  private List<HuiShuiStatusBean> mHuiShuiList = new ArrayList();
  private PullToRefreshListView mPullRefreshListView;
  private int memberid;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131099699:
        CustomApplication.app.finishActivity(HuiShuiActivity.this);
        return;
      case 2131099704:
        HuiShuiActivity.this.startActivity(new Intent(HuiShuiActivity.this, CustomServiceActivity.class));
        return;
      case 2131099860:
      }
      Intent localIntent = new Intent(HuiShuiActivity.this, BackRuleActivity.class);
      localIntent.putExtra("bean", HuiShuiActivity.this.huiShuiListBean);
      HuiShuiActivity.this.startActivity(localIntent);
    }
  };
  private int page = 1;
  private RadioButton rb_title1;
  private RadioButton rb_title2;
  private RadioButton rb_title3;
  private ArrayList<ReturnwaterResultBaseBean> result = new ArrayList();
  private RadioGroup rg_top_tag;
  private HuiShuiStatusBean selectMap = new HuiShuiStatusBean();
  private TextView tv_guize;
  private View view_title;

  private void getRecordList(String paramString)
  {
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("page", this.page);
    localHashMap.put("pagesize", "10");
    localHashMap.put("ctype", paramString);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_RETURN_WATER_LIST);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_GET_RETURN_WATER_LIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        HuiShuiActivity.this.dismissLoadingDialog();
        LogUtils.e(HuiShuiActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
        HuiShuiActivity.this.mPullRefreshListView.onRefreshComplete();
        HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
      }

      public void onResponse(String paramAnonymousString)
      {
        HuiShuiActivity.this.dismissLoadingDialog();
        HuiShuiActivity.this.mPullRefreshListView.onRefreshComplete();
        LogUtils.d(HuiShuiActivity.this.TAG, "result:" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
        {
          LogUtils.d(HuiShuiActivity.this.TAG, "result:" + paramAnonymousString);
          HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
        }
        ReturnwaterResultModel localReturnwaterResultModel;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localReturnwaterResultModel = (ReturnwaterResultModel)localGson.fromJson(paramAnonymousString, ReturnwaterResultModel.class);
            if (localReturnwaterResultModel == null)
            {
              LogUtils.e(HuiShuiActivity.this.TAG, "获取失败");
              HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localReturnwaterResultModel = null;
            }
            if (localReturnwaterResultModel.getFlag() == 0)
            {
              LogUtils.e(HuiShuiActivity.this.TAG, "returnwaterResultModel.getFlag() != 1,0,-2");
              HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
              return;
            }
            if (localReturnwaterResultModel.getFlag() == -2)
            {
              HuiShuiActivity.this.showDownWireDialog();
              return;
            }
            if (localReturnwaterResultModel.getFlag() == -3)
            {
              HuiShuiActivity.this.ShowFengjinDialog();
              return;
            }
            if (localReturnwaterResultModel.getFlag() == -4)
            {
              HuiShuiActivity.activityStack.backToMain(MainActivity.class, HuiShuiActivity.this.context);
              return;
            }
          }
        }
        while (localReturnwaterResultModel.getFlag() != 1);
        if (localReturnwaterResultModel.getResult() == null)
        {
          LogUtils.e(HuiShuiActivity.this.TAG, "bean.getResult() == null");
          return;
        }
        if ((HuiShuiActivity.this.result != null) && (HuiShuiActivity.this.isClear))
          HuiShuiActivity.this.result.clear();
        HuiShuiActivity.this.result.addAll(localReturnwaterResultModel.getResult());
        if ((HuiShuiActivity.this.result == null) || (HuiShuiActivity.this.result.size() == 0))
          HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
        if (localReturnwaterResultModel.getResult().size() < 10);
        for (HuiShuiActivity.this.isEnd = true; ; HuiShuiActivity.this.isEnd = false)
        {
          HuiShuiActivity.this.adapter.setData(HuiShuiActivity.this.result);
          HuiShuiActivity.this.adapter.notifyDataSetChanged();
          return;
        }
      }
    });
  }

  private void getStatusList()
  {
    HashMap localHashMap = new HashMap();
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GETRETURNWATERSTATE);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_GETRETURNWATERSTATE, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        HuiShuiActivity.this.dismissLoadingDialog();
        LogUtils.e(HuiShuiActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        HuiShuiActivity.this.dismissLoadingDialog();
        LogUtils.d(HuiShuiActivity.this.TAG, "result:" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
          LogUtils.d(HuiShuiActivity.this.TAG, "result:" + paramAnonymousString);
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            HuiShuiActivity.this.huiShuiListBean = ((HuiShuiListBean)localGson.fromJson(paramAnonymousString, HuiShuiListBean.class));
            if (HuiShuiActivity.this.huiShuiListBean == null)
            {
              LogUtils.e(HuiShuiActivity.this.TAG, "获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              HuiShuiActivity.this.huiShuiListBean = null;
              localException.printStackTrace();
            }
            if (HuiShuiActivity.this.huiShuiListBean.getFlag() == 0)
            {
              LogUtils.e(HuiShuiActivity.this.TAG, "returnwaterResultModel.getFlag() != 1,0,-2");
              return;
            }
            if (HuiShuiActivity.this.huiShuiListBean.getFlag() == -2)
            {
              HuiShuiActivity.this.showDownWireDialog();
              return;
            }
            if (HuiShuiActivity.this.huiShuiListBean.getFlag() == -3)
            {
              HuiShuiActivity.this.ShowFengjinDialog();
              return;
            }
            if (HuiShuiActivity.this.huiShuiListBean.getFlag() == -4)
            {
              HuiShuiActivity.activityStack.backToMain(MainActivity.class, HuiShuiActivity.this.context);
              return;
            }
          }
        }
        while (HuiShuiActivity.this.huiShuiListBean.getFlag() != 1);
        if (HuiShuiActivity.this.huiShuiListBean.getResult() == null)
        {
          LogUtils.e(HuiShuiActivity.this.TAG, "bean.getResult() == null");
          return;
        }
        HuiShuiActivity.this.mHuiShuiList = HuiShuiActivity.this.huiShuiListBean.getResult();
        HuiShuiActivity.this.rg_top_tag.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
        {
          public void onCheckedChanged(RadioGroup paramAnonymous2RadioGroup, int paramAnonymous2Int)
          {
            int i = paramAnonymous2RadioGroup.getCheckedRadioButtonId();
            RadioButton localRadioButton = (RadioButton)HuiShuiActivity.this.findViewById(i);
            HuiShuiActivity.this.selectMap = ((HuiShuiStatusBean)localRadioButton.getTag());
            HuiShuiActivity.this.page = 1;
            HuiShuiActivity.this.isClear = true;
            HuiShuiActivity.this.getRecordList(HuiShuiActivity.this.selectMap.getLevel_type());
          }
        });
        int i = 0;
        int j = 0;
        label315: HuiShuiStatusBean localHuiShuiStatusBean;
        if (j < HuiShuiActivity.this.mHuiShuiList.size())
        {
          localHuiShuiStatusBean = (HuiShuiStatusBean)HuiShuiActivity.this.mHuiShuiList.get(j);
          if (localHuiShuiStatusBean.getRule_state() != 0)
            break label365;
        }
        while (true)
        {
          j++;
          break label315;
          break;
          label365: RadioGroup.LayoutParams localLayoutParams = new RadioGroup.LayoutParams(-2, -2);
          localLayoutParams.setMargins(10, 0, 10, 0);
          RadioButton localRadioButton = (RadioButton)LayoutInflater.from(HuiShuiActivity.this).inflate(2130903216, null);
          localRadioButton.setText(localHuiShuiStatusBean.getLevel_name());
          localRadioButton.setLayoutParams(localLayoutParams);
          localRadioButton.setTag(localHuiShuiStatusBean);
          HuiShuiActivity.this.rg_top_tag.addView(localRadioButton);
          if (i == 0)
          {
            localRadioButton.setChecked(true);
            localRadioButton.performClick();
            i = 1;
          }
        }
      }
    });
  }

  private void init()
  {
    this.rg_top_tag = ((RadioGroup)findViewById(2131099835));
    this.rb_title1 = ((RadioButton)findViewById(2131099836));
    this.rb_title2 = ((RadioButton)findViewById(2131099837));
    this.rb_title3 = ((RadioButton)findViewById(2131099861));
    this.rg_top_tag.check(2131099836);
    this.rg_top_tag.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
    {
      public void onCheckedChanged(RadioGroup paramAnonymousRadioGroup, int paramAnonymousInt)
      {
        switch (paramAnonymousInt)
        {
        default:
          return;
        case 2131099836:
          HuiShuiActivity.this.ctype = "1";
          HuiShuiActivity.this.page = 1;
          HuiShuiActivity.this.isClear = true;
          HuiShuiActivity.this.getRecordList(HuiShuiActivity.this.ctype);
          return;
        case 2131099837:
          HuiShuiActivity.this.ctype = "2";
          HuiShuiActivity.this.page = 1;
          HuiShuiActivity.this.isClear = true;
          HuiShuiActivity.this.getRecordList(HuiShuiActivity.this.ctype);
          return;
        case 2131099861:
        }
        HuiShuiActivity.this.ctype = "2";
        HuiShuiActivity.this.page = 1;
        HuiShuiActivity.this.isClear = true;
        HuiShuiActivity.this.getRecordList(HuiShuiActivity.this.ctype);
      }
    });
    this.emptyView = LayoutInflater.from(this.context).inflate(2130903139, null);
    ((TextView)this.emptyView.findViewById(2131100053)).setText("暂无回水记录");
    this.mPullRefreshListView = ((PullToRefreshListView)findViewById(2131099717));
    this.mPullRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
    this.mPullRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(HuiShuiActivity.this.getApplicationContext(), System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (HuiShuiActivity.this.mPullRefreshListView.isHeaderShown())
        {
          HuiShuiActivity.this.isRefesh = true;
          LogUtils.e(HuiShuiActivity.this.TAG, "mPullRefreshListView刷新");
          HuiShuiActivity.this.refeshRecordList(HuiShuiActivity.this.selectMap.getLevel_type());
          return;
        }
        HuiShuiActivity.this.isRefesh = false;
        LogUtils.e(HuiShuiActivity.this.TAG, "mPullRefreshListView加载");
        if (HuiShuiActivity.this.isEnd)
          UiUtil.showToast(HuiShuiActivity.this.context, "暂无更多数据");
        HuiShuiActivity localHuiShuiActivity = HuiShuiActivity.this;
        localHuiShuiActivity.page = (1 + localHuiShuiActivity.page);
        HuiShuiActivity.this.isClear = false;
        HuiShuiActivity.this.getRecordList(HuiShuiActivity.this.selectMap.getLevel_type());
      }
    });
    this.mPullRefreshListView.setOnLastItemVisibleListener(new PullToRefreshBase.OnLastItemVisibleListener()
    {
      public void onLastItemVisible()
      {
        LogUtils.d(HuiShuiActivity.this.TAG, "End of List!");
      }
    });
    SoundPullEventListener localSoundPullEventListener = new SoundPullEventListener(this);
    localSoundPullEventListener.addSoundEvent(PullToRefreshBase.State.PULL_TO_REFRESH, 2131034114);
    localSoundPullEventListener.addSoundEvent(PullToRefreshBase.State.RESET, 2131034116);
    localSoundPullEventListener.addSoundEvent(PullToRefreshBase.State.REFRESHING, 2131034115);
    if (this.adapter == null)
    {
      this.adapter = new ReturnwaterListAdapter(this.context, this.result);
      this.mPullRefreshListView.setAdapter(this.adapter);
    }
    this.adapter.notifyDataSetChanged();
  }

  private void refeshRecordList(String paramString)
  {
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    this.page = 1;
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("page", this.page);
    localHashMap.put("pagesize", "10");
    localHashMap.put("ctype", paramString);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_RETURN_WATER_LIST);
    RequestNet.get(this.context, AppConstants.URL_GET_RETURN_WATER_LIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(HuiShuiActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
        HuiShuiActivity.this.mPullRefreshListView.onRefreshComplete();
        HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
      }

      public void onResponse(String paramAnonymousString)
      {
        HuiShuiActivity.this.mPullRefreshListView.onRefreshComplete();
        LogUtils.d(HuiShuiActivity.this.TAG, "result:" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
        {
          LogUtils.d(HuiShuiActivity.this.TAG, "result:" + paramAnonymousString);
          HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
        }
        ReturnwaterResultModel localReturnwaterResultModel;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localReturnwaterResultModel = (ReturnwaterResultModel)localGson.fromJson(paramAnonymousString, ReturnwaterResultModel.class);
            if (localReturnwaterResultModel == null)
            {
              LogUtils.e(HuiShuiActivity.this.TAG, "获取失败");
              HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localReturnwaterResultModel = null;
            }
            if (localReturnwaterResultModel.getFlag() == 0)
            {
              LogUtils.e(HuiShuiActivity.this.TAG, "returnwaterResultModel.getFlag() != 1,0,-2");
              HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
              return;
            }
            if (localReturnwaterResultModel.getFlag() == -2)
            {
              HuiShuiActivity.this.showDownWireDialog();
              return;
            }
            if (localReturnwaterResultModel.getFlag() == -3)
            {
              HuiShuiActivity.this.ShowFengjinDialog();
              return;
            }
            if (localReturnwaterResultModel.getFlag() == -4)
            {
              HuiShuiActivity.activityStack.backToMain(MainActivity.class, HuiShuiActivity.this.context);
              return;
            }
          }
        }
        while (localReturnwaterResultModel.getFlag() != 1);
        if (localReturnwaterResultModel.getResult() == null)
        {
          LogUtils.e(HuiShuiActivity.this.TAG, "bean.getResult() == null");
          return;
        }
        if (HuiShuiActivity.this.result != null)
          HuiShuiActivity.this.result.clear();
        HuiShuiActivity.this.result.addAll(localReturnwaterResultModel.getResult());
        if ((HuiShuiActivity.this.result == null) || (HuiShuiActivity.this.result.size() == 0))
        {
          LogUtils.e(HuiShuiActivity.this.TAG, "result:" + HuiShuiActivity.this.result);
          HuiShuiActivity.this.mPullRefreshListView.setEmptyView(HuiShuiActivity.this.emptyView);
        }
        HuiShuiActivity.this.adapter.setData(HuiShuiActivity.this.result);
        HuiShuiActivity.this.adapter.notifyDataSetChanged();
      }
    });
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903060);
    CustomApplication.app.addActivity(this);
    this.context = this;
    this.tv_guize = ((TextView)findViewById(2131099860));
    this.tv_guize.getPaint().setFlags(8);
    this.tv_guize.setOnClickListener(this.onClickListener);
    setTitle(8, 0, 2130837809, "我的回水", 0, 8, 0, 2130837847, true);
    init();
    getStatusList();
  }

  protected void onResume()
  {
    super.onResume();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.HuiShuiActivity
 * JD-Core Version:    0.6.2
 */